<template>
	<view class="container">
		<view>
			<!-- 新闻列表 -->
			<view class="newsListe">
				<view class="newsFor" v-for="(news,indexs) in data.newsIndex" :key="indexs" @click="$goURl('/pages/news/newsDetails?id='+news.ID)">
					<!-- 新闻左侧 -->
					<view class="newsLeft">
						<text class="newsText">{{news.title}}</text>
						<view class="newsMtd">
							<text class="browse">{{news.click}}次浏览</text>
							<text class="browse">{{$clearTime(news.CreatedAt)}}</text>
						</view>
					</view>
					<!-- 新闻右侧 -->
					<view class="newsRight">
						<image class="newsImg" :src="news.img"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {ref,reactive,getCurrentInstance} from "vue";
	import {onLoad,onShow,onPullDownRefresh,onReachBottom} from "@dcloudio/uni-app";
	const {proxy} = getCurrentInstance();
	let userInfo = ref({})
	let data = reactive({
		page:0,
		size:50,
		pages:1,
		newsList: [],		//新闻导航栏
		bannerImg:[],		//轮播图
		navigColor:1,		//点击获取id
		currentst:0,
		keyword:'',
		newsIndex:[],		//新闻列表
	})
	onPullDownRefresh(()=> {
			newsLists()
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000)
		})
	onReachBottom(()=>{
		console.log('onReachBottom')
	})
	onLoad((option) => {
		console.log('页面onLoad')
		data.keyword=option.keyword
	})
	onShow(() => {
		console.log('页面onShow')
		newsLists()
	})
	//新闻列表
	function newsLists(){
		proxy.$request({
			url:`api/newsList/0/?page=${data.page}&size=${data.size}&keyword=${data.keyword}`,
			method:'GET',
			success:(res)=>{
				data.newsIndex = res.data.data
				let min = res.data.data
				min.forEach((ct)=>{
					if(ct.is_hot==1){
						data.bannerImg.push(ct)
					}
				})
			}
		})
	}
</script>

<style lang="scss" scoped>
	page{
		background: #fff;
	}
	// 顶部搜索框
	.searchMd {
		width: 96%;
		display: flex;
		align-items: center;
		margin: 40rpx auto 0 auto;
		.searImgs{
			width: 50rpx !important;
			height: 50rpx !important;
		}
		.searchBox {
			width: 90%;
			border: 1rpx solid rgba(238, 3, 3, 0.15);
			background: #ffffff;
			border-radius: 34rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 4rpx 4rpx 4rpx 20rpx;
			margin-left: 8rpx;
		}

		.searchText {
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			text-align: left;
			color: #cfcfcf;
			letter-spacing: 0rpx;
		}

		.searchBottm {
			background: #ee0303;
			border-radius: 34rpx;
			padding: 6rpx 34rpx 4rpx 34rpx;
		}

		.searchBottmText {
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			text-align: left;
			color: #ffffff;
			letter-spacing: 2rpx;
			line-height: 48rpx;
		}
	}
	// 新闻导航
	.newsConten {
		width: 96%;
		margin: 20rpx auto;

		.scroll-view_H {
			white-space: nowrap;
			width: 100%;
		}

		.newsNext {
			display: flex;
		}

		.newsFor {
			width: 100%;
			font-size: 30rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			text-align: left;
			color: #333333;
			letter-spacing: 0rpx;
			padding: 0 10rpx;
		}
		.newsNaver{
			width: 55px;
			display: block;
		}
		.actve{
			font-size: 32rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			text-align: left;
			color: #000000;
			letter-spacing: 0.02rpx;
		}
	}
	// 轮播图
	.content{
		width: 96%;
		margin: 0 auto;
		position: relative;
		.swiper-item{
			border-radius: 20px;
		}
		.popular{
			width: 94%;
			position: absolute;
			left: 0;
			bottom: 10%;
			padding: 0px 30rpx;
			display: flex;
			flex-direction: column;
		}
		.prpuMpp{
			width: 8%;
			background: #ee0303;
			border-radius: 8rpx;
			font-size: 24rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			text-align: left;
			color: #ffffff;
			letter-spacing: 1rpx;
			padding: 4rpx 10rpx;
		}
		.popularText{
			font-size: 32rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			text-align: left;
			color: #ffffff;
			letter-spacing: 1rpx;
			overflow:hidden;
			text-overflow:ellipsis;
			display:-webkit-box;
			-webkit-box-orient:vertical;
			-webkit-line-clamp:1; // 想要超出三行显示 就把这里改成3就好了
		}
	}
	// 新闻列表
	.newsListe{
		width: 96%;
		margin: 0 auto;
		.newsFor{
			display: flex;
			border-bottom: 1px solid #ccc;
			margin-top: 20rpx;
			padding: 20rpx 0;
		}
		.newsLeft{
			width: 70%;
			padding: 0 20rpx 0 0;
		}
		.newsText{
			font-size: 30rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			text-align: left;
			color: #333333;
			letter-spacing: 1rpx;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			overflow: hidden;
		}
		.newsMtd{
			width: 100%;
			margin-top: 30px;
			display: flex;
			justify-content: space-between;
		}
		.browse{
			font-size: 24rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			text-align: left;
			color: #999999;
			letter-spacing: 1rpx;
			margin-right: 20rpx;
		}
		.newsRight{
			width: 30%;
		}
		.newsImg{
			height: 200rpx !important;
		}
	}
	uni-image{
		width: 100% !important;
		height: 100% !important;
		object-fit: cover;
		border-radius: 28rpx;
	}
	.swiper-item{
		height: 100% !important;
	}
	uni-swiper{
		height: 400rpx !important;
	}
	::v-deep .uni-swiper__dots-box{
		justify-content: flex-end !important;
		padding: 0 20rpx 0 0;
	}
	uni-video{
		width: 100% !important;
		height: 100% !important;
	}
</style>
<style>
	page{
		background-color: #fff;
	}
</style>